package com.server.api.enums;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description: 通用状态枚举类
 * @Author: wuming
 */
@AllArgsConstructor
@Getter
public enum CommonStatusEnum {

    STATUS_1(1, "可用"),

    STATUS_2(2, "不可用");

    /**
     * 状态码
     */
    private Integer code;

    /**
     * 文本值
     */
    private String value;

    public static Map<Integer, CommonStatusEnum> SOURCE = new HashMap<>(1 << 5);

    static {
        for (CommonStatusEnum commonStatusEnum : CommonStatusEnum.values()) {
            SOURCE.put(commonStatusEnum.getCode(), commonStatusEnum);
        }
    }

    public static CommonStatusEnum getByCode(int code) {
        return SOURCE.get(code);
    }

}
